import React , { Component } from 'react';
import axios from 'axios';
import { withRouter,NavLink} from 'react-router-dom';
import {observer,inject} from 'mobx-react';

// 导入需要的模块
@withRouter
@inject('first')
@observer
class View extends Component{

    async getApi(url,cfg,headers){
        let data = await axios.get(url,{params:cfg},
        {
            headers: headers
        })
        return data;
    }
    ajax(){
        const cfg = {
            page_number:'2',
            page_size:'10'
        }
        this.getApi('/home/mediareports',cfg,{}).then((res)=>{
            console.log(res.data)
        })
    }
    componentDidMount(){
        this.ajax()
    }
    render(){
        console.log(this.props.first)
        return(
            <React.Fragment>
            <NavLink to="/">首页</NavLink><br/>
            <NavLink to="/input">表单</NavLink><br/>
            <NavLink to="/event">事件</NavLink><br/>
            <NavLink to="/storedemo">storedemo</NavLink><br/>
            <NavLink to="/observable">observable</NavLink><br/>
            <NavLink to="/newobs">newobs</NavLink><br/>
            <div>这是新的storeDemo页面</div>
            </React.Fragment>
        )
    }

}
export default View;
